//reducer 函数
let init = {value:0};
// {type: 'jia', payload: 1};
// {type: 'jian', payload: 1};
let zanReducer = (state=init, action) => {
  //根据 action type 的类型, 对状态进行更新
  switch(action.type){
    case 'jia':
      return {
        value: state.value + action.payload
      }
    case 'jian':
      return {
        value: state.value - action.payload
      }
    default:
      return state;
  }
}

//状态 action creator
export let jiaAction = payload => ({type: 'jia', payload:payload })
export let jianAction = payload => ({type: 'jian', payload: payload});

export default zanReducer;